// components/workTimeDialog/workTime.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    sWorkDate:{
      type:Number,
      value:-1
    },
    sShift:{
      type:Number,
      value:-1
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    workDateType:[
      // { name: "工作日", id:6 },
      { name: "周末", id: 0 },
      { name: "做一休一", id: 1 },
      { name: "做二休一", id: 2 },
      { name: "做二休二", id: 3 },
      { name: "做五休二", id: 4 },
      { name: "做六休一", id: 5 }
    ],
    shiftType:[
      { name: "早班", id:1 },
      { name: "中班", id:2 },
      { name: "晚班", id:3 }
    ],

    sWorkDate:-1,
    sShift:-1,
  },

  lifetimes:{
    //可以再此生命周期获取父组件传递给子组件数据
    //this.data.sWorkDate
    ready:function(){
      
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    selectWorkDateType(e){
      let currentId = e.currentTarget.dataset.id;
      if(this.data.sWorkDate == currentId){
        this.setData({sWorkDate:-1});
      }else{
        this.setData({sWorkDate:currentId});
      }
    },

    selectShiftType(e){
      let currentId = e.currentTarget.dataset.id;
      if(this.data.sShift == currentId){
        this.setData({sShift:-1});
      }else{
        this.setData({sShift:currentId});
      }
    },


    reset(){
      this.setData({sShift:-1,sWorkDate:-1});
      this.triggerEvent("workTimeListener",{
        sWorkDate:-1,
        sShift:-1,
        reset:true
      });
    },

    config(){
      let that = this;
      this.triggerEvent("workTimeListener",{
        sWorkDate:that.data.sWorkDate,
        sShift:that.data.sShift,
        reset:false
      });
    }
  }
})

